<{include file="Public:header" /}>
<div id="page-wrapper">
	<div class="row">
		<div class="col-lg-12">
			<h1 class="page-header" style="margin-top: 0px;"></h1>
		</div>
		<!-- /.col-lg-12 -->
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					<b>建筑管理</b>
				</div>
				<!-- /.panel-heading -->
				<div class="panel-body">
					<div class="dataTable_wrapper">
						<div id="dataTables-example_wrapper"
							class="dataTables_wrapper form-inline dt-bootstrap no-footer">
							<div class="row">

								<div class="col-sm-6">
									<form action="<{:Url('Place/building')}>" method="get">
										<div class="dataTables_filter" style="float: left;">
											<label>建筑名称: <input type="search" name="name"
												class="form-control input-sm" placeholder="">
											</label>
											<button class='btn btn-primary'>查询</button>
										</div>
									</form>
									<button class='btn btn-success'
										style="float: left; margin-left: 6px" onclick="addbuilding()">添加建筑</button>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-12">
									<table id="yao_table"
										class="table table-striped table-bordered table-hover dataTable no-footer">
										<thead>
											<tr role="row">
												<th style="text-align: center;">所属城市</th>
												<th style="text-align: center;">广场名称</th>
												<th style="text-align: center;">建筑名称</th>
												<th style="text-align: center;">ap数量</th>
												<th style="text-align: center;">操作</th>

											</tr>
										</thead>
										<tbody>
											<{volist name="list" id='vo' }>
											<tr class="gradeA odd" role="row">
												<td><{$vo.location_name}></td>
												<td><{$vo.campus_name}></td>
												<td><{$vo.building_name}></td>
												<td><{notempty name="vo.cnt" }> <{$vo.cnt}> <{else /}>0
													<{/notempty}></td>
												<td><a class="eduitbuilding" href="javascript:void(0)"
													onclick="eduitbuilding('<{$vo.id}>','<{$vo.campusId}>','<{$vo.building_name}>')">编辑</a>
													| <a class="deletebuilding" href="javascript:void(0)"
													onclick="deletebuilding('<{$vo.id}>')">删除</a></td>

											</tr>
											<{/volist}>

										</tbody>
									</table>
								</div>
							</div>

							<div class="row">
								<div class="col-sm-12">
									<div class='pages'><{$show}></div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- /.panel-body -->
			</div>
			<!-- /.panel -->
		</div>
		<!-- /.col-lg-12 -->
	</div>

</div>

<!-- 添加楼层信息-->
<div id="addbuilding" class="hide">
	<form class="form-horizontal">
		<div class="row">
			<div class="control-group span8">

				<label class="control-label" style="padding-top: 0px;">广场名称：</label>
				<div class="controls">
					<select id="campusId" name="campusId"> <{volist
						name="square" id='vo' }>
						<option value="<{$vo.id}>">
									<{$vo.campus_name}>
								</option> <{/volist}>
					</select>
				</div>
			</div>
			<div class="control-group span8">
				<label class="control-label" style="padding-top: 0px;">建筑名称：</label>
				<div class="controls">
					<input type="text" id="building_name"
						class="input-normal control-text" style="height: 30px;">
				</div>
			</div>
		</div>
	</form>
</div>
<!--     <form method="post" enctype="multipart/form-data" action="__URL__/upload">
        附件：<input type="file" name="image" />
    <input type="submit" value="提交">
    </form> -->

<!-- 编辑建筑-->
<div id="eduitbuilding" class="hide">
	<!--     action+"__URL__/upload" enctype="multipart/form-data" method="post" -->
	<form class="form-horizontal">
		<div class="row">
			<div class="control-group span10">
				<label class="control-label" style="padding-top: 0px; width: 140px">广场名称：</label>
				<div class="controls">
					<select id="campusIds" name="campusId"> <{volist
						name="square" id='vo' }>
						<option value="<{$vo.id}>">
									<{$vo.campus_name}>
								</option> <{/volist}>
					</select>
				</div>
			</div>
			<div class="control-group span8">
				<label class="control-label" style="padding-top: 0px; width: 140px">建筑名称：</label>
				<div class="controls">
					<input type="text" id="building_name1"
						class="input-normal control-text" style="height: 30px;">
				</div>
			</div>
			<div class="control-group span8" style="display: none;">
				<label class="control-label" style="padding-top: 0px; width: 140px">建筑名称：</label>
				<div class="controls">
					<input type="text" id="id" class="input-normal control-text">
				</div>
			</div>

		</div>
	</form>
</div>

<script src="__PUBLIC__/js/jquery-1.8.3.min.js" type="text/javascript">
	
</script>
<script src="__PUBLIC__/js/bui.js"></script>
<script type="text/javascript">
	var Overlay = BUI.Overlay;
	$(document).ready(function() {

		$("#checkedAll").click(function() {
			if ($(this).prop('checked')) { // 全选 
				$("input[name='checkbox_name']").each(function() {
					$(this).prop('checked', true);
				});
			} else { // 取消全选 
				$("input[name='checkbox_name']").each(function() {
					$(this).prop('checked', false);
					;
				});
			}
		});

	});
	//编辑
	function eduitbuilding(id, campusId, building_name) {
		$('#id').val(id);
		$('#campusIds').val(campusId);
		$('#building_name1').val(building_name);
		var dialog = new Overlay.Dialog({
			title : '修改建筑信息',
			width : 450,
			height : 400,
			closeAction : 'destroy', //每次关闭dialog释放
			contentId : 'eduitbuilding',
			buttons : [ {
				text : '提交修改',
				elCls : 'button button-primary',
				handler : function() {
					$id = $('#id').val();
					$campusId = $('#campusIds').val();
					$building_name = $('#building_name1').val();
					$.post("<{:Url('Place/ajaxeduitbuilding')}>", {
						'id' : $id,
						'campusId' : $campusId,
						'building_name' : $building_name
					}, function(data) {
						if (data) {
							dispoint("修改建筑信息成功");
							dialog.close();
							location.reload();
						} else {
							dispoint("修改建筑信息失败");
						}
					})
				}
			}, {
				text : '取消',
				elCls : 'button',
				handler : function() {
					this.close();
				}
			} ]
		});
		dialog.show();
	}
	//添加建筑
	function addbuilding() {
		var dialog = new Overlay.Dialog({
			title : '新增建筑信息',
			width : 450,
			height : 200,
			closeAction : 'destroy', //每次关闭dialog释放
			contentId : 'addbuilding',
			buttons : [ {
				text : '确定',
				elCls : 'button button-primary',
				handler : function() {
					$campusId = $('#campusId').val();
					$building_name = $('#building_name').val();
					$.post('<{:Url("Place/ajaxaddbuilding")}>', {
						'campusId' : $campusId,
						'building_name' : $building_name
					}, function(data) {
						if (data != 'error') {
							dispoint("新增建筑信息成功");
							dialog.close();
							location.reload();
						} else {
							dispoint("新增建筑信息失败!可能是建筑名称重复");
						}
					})
				}
			}, {
				text : '取消',
				elCls : 'button',
				handler : function() {
					this.close();
				}
			} ]
		});
		dialog.show();
	}

	function deletebuilding(id) {
		BUI.Message.Confirm('确认要删除？', function() {
			setTimeout(function() {
				$.ajax({
					type : 'post',
					url : '<{:Url("Place/ajaxdeletebuilding")}>',
					data : {
						'id' : id
					},
					dataType : 'json',
					success : function(msg) {
						dispoint("删除成功！");
						location.reload();
					}
				});

				//BUI.Message.Alert('这只是简单的错误信息','error');
			});

		}, 'question');
	}
</script>

<!-- 删除用户 -->
<script type="text/javascript">
	//消息消失
	function dispoint(messge) {
		BUI.Message.Show({
			msg : messge,
			icon : 'success',
			buttons : [],
			autoHide : true,
			autoHideDelay : 1000

		});
	}

	function show(hidden) {
		BUI.Message.Confirm('确认要删除？', function() {
			setTimeout(function() {
				$.ajax({
					type : 'get',
					url : "<{:Url('Place/delCommager','id=')}>" + hidden,
					success : function(msg) {
						dispoint("删除成功！");
						location.reload();
					}
				});

				//BUI.Message.Alert('这只是简单的错误信息','error');
			});

		}, 'question');
	}
</script>
<include file="Public:footer" />